package com.gem.entity;

import com.gem.enums.GemType;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * Author: Xhy
 * CreateTime: 2022-09-17 15:48
 */
@Data
public class Gem {
    GemType type;
    Integer count;


    private static Map<Integer,String> gems = new HashMap<>();

    static {
        gems.put(GemType.BLUE.type,"蓝宝石");
        gems.put(GemType.RED.type,"红宝石");
        gems.put(GemType.BLACK.type,"黑宝石");
        gems.put(GemType.GREEN.type,"绿宝石");
        gems.put(GemType.WHITE.type,"白宝石");
        gems.put(GemType.GOLD.type,"黄金");

    }

    public static String getGemInfo(Integer type){
        return gems.get(type);
    }


    // key:宝石类型，value:宝石数量
    private Map<Integer,Integer> gemInfo;

    public static Map<Integer,Integer> initGems(int limit){
        HashMap<Integer, Integer> gems = new HashMap<>();

        // 根据人数限制
        int number = 7;

        if (limit == 3){
            number = 5;
        }else if (limit == 2){
            number =4;
        }
        gems.put(GemType.BLUE.getType(),number);
        gems.put(GemType.RED.getType(),number);
        gems.put(GemType.BLACK.getType(),number);
        gems.put(GemType.GREEN.getType(),number);
        gems.put(GemType.WHITE.getType(),number);
        gems.put(GemType.GOLD.getType(),5);


        return gems;
    }

    public Gem(){
        gemInfo = new HashMap<>();
    }

    public Gem red(Integer number){
        gemInfo.put(2,number);
        return this;
    }

    public Gem black(Integer number){
        gemInfo.put(3,number);
        return this;
    }
    public Gem white(Integer number){
        gemInfo.put(5,number);
        return this;
    }
    public Gem green(Integer number){
        gemInfo.put(4,number);

        return this;
    }
    public Gem blue(Integer number){
        gemInfo.put(1,number);
        return this;
    }

    public Map<Integer, Integer> toMap() {
        return this.gemInfo;
    }


}
